<?php
	class db {
		
		function connect($server=SYSTEM_DATABASE_SERVER, $username=SYSTEM_DATABASE_USER, $password=SYSTEM_DATABASE_PASS, $databaseName=SYSTEM_DATABASE_NAME) {
			/*
			 * Summary: Connects to the database and returns a mysql database link
			 * @param  string 	$server 		IP address of server
			 * @param  string 	$username 		Username of the database user
			 * @param  string 	$password 		Password for the database
			 * @param  string 	$databasename 	Name of the database
			 * @return database					Database link
			 */		
			 
			 $dbsLink = mysql_connect($server, $username, $password);
			 
			 if(!$dbsLink) {
				//Ugh, damn! Log the error.
				err::log('MySQL Error', mysql_error(), 'flat');
				return(false);
			 } else {
				//We're in! Now select the database
				$dbLink = mysql_select_db($databaseName, $dbsLink);
				if($dbLink) {
					return($dbLink);
				} else {
					err::log('MySQL Error', mysql_error(), 'flat');
					return false;
				}
			 }
		}

	}
?>